home *** CD-ROM | disk | FTP | other *** search
- {Copyright (c)-Fernando Padilla January 19, 1993}
- program problem3at1992;
- uses
- p31992u,crt;
-
- function rectangles:word;
- var
- numberofrectangles:word;
- x:word;
- point1,point2:pointtype;
- begin
- numberofrectangles:=0;
- x:=0;
- repeat
- gotolinenumber(x);
- while not(pos('1',linepointing^.image)=0) do
- begin
- point1.x:=x;
- point1.y:=pos('1',linepointing^.image);
- point2.x:=point1.x;
- point2.y:=point1.y;
- expand(point2);
- if testrectangle(point1,point2) then
- begin
- clearrectangle(point1,point2);
- inc(numberofrectangles);
- end;
- end;
- gotolinenumber(x);
- inc(x);
- until linepointing^.next=nil;
- rectangles:=numberofrectangles;
- end;
-
- procedure batchinputdata(var batchfile:text);
- var
- temp:string[80];
- batchingfile:text;
- begin
- assign(batchingfile,'a:p3-data.dat');
- reset(batchingfile);
-
- repeat
- readln(batchingfile,temp);
- writeln(temp);
- writeln(batchfile,temp);
- until eof(batchingfile);
- close(batchingfile);
- end;
-
- procedure inputdata(var batchfile:text);
- var
- temp:string[80];
- begin
- linepointing:=nil;
- repeat
- readln(temp);
- writeln(batchfile,temp);
- until eof;
- end;
-
- procedure outputdata(var batchfile:text);
- begin
- reset(batchfile);
- repeat
- addimage(batchfile);
- writeln(rectangles);
- removeimage;
- until eof(batchfile);
- end;
-
- procedure control;
- var
- batchfile:text;
- begin
- clrscr;
- assign(batchfile,'a:tempfile.dat');
- rewrite(batchfile);
-
- { inputdata(batchfile);}
- batchinputdata(batchfile);
- outputdata(batchfile);
- close(batchfile);
- erase(batchfile);
- end;
-
-
- begin
- control;
- end.
-